import { getAreaObj } from '@/utils/util'

import {configToSearch,toSearchHandle} from '@/views/datacenter/business/utils/index'



// import { uploadType } from '@/utils/util'
const tableConfig = {
	stripe: true,
	border: true,
	maxHeight: '80vh',
	columns: [
		{
			label: '所属区域',
			prop: 'belongAreaName',
			changeField: true,
		},
		// { label: '统一社会信用代码', prop: 'creditCode' },
		{ label: '机构名称', prop: 'organizationName' },
		{ label: '联系人', prop: 'deputyUserName' },
		{ label: '联系方式', prop: 'organizationPhone',plusXing: '5,2' },
		{ label: '申请总人数', prop: 'applyPeopleTotal' },
		{ label: '申请总金额', prop: 'applyAmountTotal' },
		{
			label: '申请年月',
			prop: 'applyDate',
			type: 'date',
			format: 'YYYY年MM月DD日',
			valueFormat: 'YYYY-MM-DD',
		},
		{
			label: '是否可信',
			prop: 'isBelievable',
			custome: 'tag',
			dicData: [
				{ label: '否', value: 0,type:'danger' },
				{ label: '是', value: 1,type:'success' },
			],
		},
		{
			label: '操作',
			prop: 'menu',
			width: 300,
			fixed: 'right',
		},
	],
}
const moreSet:any = {
	column:[
		{
			label:"“五类老人”补贴申请表",
			prop:"applyMaterial",
			type:"upload"
		},
		{
			label:'审核意见-审核日期',
			prop:'approvalCivilAffairDate',
			type:'date',
			format:'YYYY年MM月DD日',
			valueFormat:'YYYY-MM-DD'
		},
		{
			label:'审核意见-区民政部门意见',
			prop:"approvalCivilAffairNote",
			type: 'text',
			maxlength: '140',
			showWordLimit: true,
		},
		{
			label:"“五类老人”补贴审批结果",
			prop:'approvalResult',
			propName:"approvalResultLabel",
			api:'getDictItemList',
			code:'RESULT',
			type:"remoteSelect"
		},
		{
			label:'“五类老人”补贴审批结果驳回备注',
			prop:"approvalNote",
			type: 'text',
			maxlength: '140',
			showWordLimit: true,
		},
		{
			label:'“五类老人”补贴审批时间',
			prop:'approvalTime',
			type:'date',
			format:'YYYY年MM月DD日',
			valueFormat:'YYYY-MM-DD'
		},
		{
			label:"“五类老人”补贴审批人",
			prop:'approvalUserName',
			type: 'text',
			maxlength: '20',
			showWordLimit: true,
		},
		{
			label:'所属区划',
			prop:'belongArea',
			type:"AplidAreaSelect"
		},
		{
			label:'区民政局核准意见-申请人',
			prop:'civilApplicantName',
			type: 'text',
			maxlength: '20',
			showWordLimit: true,
		},
		{
			label:"区民政局核准意见-核准日期",
			prop:"civilApprovalDate",
			type:"date",
			format:"YYYY年MM月DD日",
			valueFormat:"YYYY-MM-DD"
		},
		{
			label:"区民政局核准意见-什么时间入住养老机构期间享受补贴",
			prop:"civilCheckinRangeDate",
			type:"date",
			format:"YYYY年MM月DD日",
			valueFormat:"YYYY-MM-DD"
		},
		{
			label:'区民政局核准意见-经办人',
			prop:"civilOperatorName",
			type: 'text',
			maxlength: '20',
			showWordLimit: true,
		},
		{
			label:'区民政局核准意见-不符合南京市困难老人入住养老机构补助条件理由',
			prop:"civilUnconformityReason",
			type: 'text',
			maxlength: '500',
			showWordLimit: true,
		},
		{
			label:"机构ID",
			prop:"creditCode",
			type: 'text',
			maxlength: '18',
			showWordLimit: true,
		},
		{
			label:"社会公示情况",
			prop:"demurStatus",
			propName:"demurStatusLabel",
			type:"select",
			dicData:[
				{label:"无异议",value:"1"},
				{label:"有异议",value:"2"},
			]
		},
		{
			label:"机构基本情况-法定代表人姓名",
			prop:"deputyUserName",
			type: 'text',
			maxlength: '20',
			showWordLimit: true,
		},
		{
			label:"社会评估机构评估结论-生活自理能力等级",
			prop:"estimateAbilityLevel",
			propName:"estimateAbilityLevelLabel",
			type:"remoteSelect",
			api:'getDictItemLsit',
			code:"ABILITY_LEVEL_CITY_STANDARD"
		},
		{
			label:'社会评估机构评估结论-申请人',
			prop:"estimateApplicantName",
			type: 'text',
			maxlength: '20',
			showWordLimit: true,
		},
		{
			label:"社会评估机构评估结论-评估日期",
			prop:"estimateDate",
			type:"date",
			format:"YYYY年MM月DD日",
			valueFormat:"YYYY-MM-DD"
		},
		{
			label:'社会评估机构评估结论-评估人',
			prop:"evaluatorName",
			type: 'text',
			maxlength: '20',
			showWordLimit: true,
		},
		{
			label:'申请内容-填报申请日期',
			prop:'fillingDate',
			type:"date",
			format:"YYYY年MM月DD日",
			valueFormat:"YYYY-MM-DD"
		},
		{
			label:'申请内容-填报负责人',
			prop:"fillingUserName",
			type: 'text',
			maxlength: '20',
			showWordLimit: true,
		},
		{
			label:"街道（乡）初审情况-生活自理能力状况",
			prop:"firstAbilityStatus",
			propName:"firstAbilityStatusLabel",
			api:"getDictItemList",
			code:'ABILITY_STATUS',
			type:"remoteSelect"
		},
		{
			label:'街道（乡）初审情况-申请人',
			prop:"firstApplicantName",
			type: 'text',
			maxlength: '20',
			showWordLimit: true,
		},
		{
			label:"街道（乡）初审情况-初审日期",
			prop:"firstDate",
			type:"date",
			format:"YYYY年MM月DD日",
			valueFormat:"YYYY-MM-DD"
		},
		{
			label:"街道（乡）初审情况-有关材料反映情况",
			prop:"firstMaterialTruth",
			propName:"firstMaterialTruthLabel",
			code:'MATERIAL_TRUTH_TYPE',
			api:"getDictItemList",
			type:"remoteSelect"
		},
		{
			label:'街道（乡）初审情况-经办人',
			prop:"firstOperatorName",
			type: 'text',
			maxlength: '20',
			showWordLimit: true,
		},
		{
			label:"审批结果-补贴发放总金额",
			prop:"grantAmount",
			append:"元",
			type:"input"
		},
		{
			label:'审批结果-补贴发放时间',
			prop:"grantDate",
			type:"date",
			format:"YYYY年MM月DD日",
			valueFormat:"YYYY-MM-DD"
		},
		{
			label:"员工概括-管理人员数量",
			prop:"orgManagerTotalNum",
			append:"人",
			type:"text"
		},
		{
			label:"员工概括-持证管理人员数量",
			prop:"orgPaperManagerNum",
			append:"人",
			type:"text"
		},
		{
			label:"员工概括-持证员工人数",
			prop:"orgPaperStaffNum",
			append:"人",
			type:"text"
		},
		{
			label:"员工概括-员工总数",
			prop:"orgStaffTotalNum",
			append:"人",
			type:"text"
		},
		{
			label:"机构基本情况-机构地址",
			prop:"organizationAddress",
			type: 'text',
			maxlength: '50',
			showWordLimit: true,
		},
		{
			label:"机构基本情况-机构设置证号",
			prop:"organizationFiling",
			type: 'text',
			maxlength: '50',
			showWordLimit: true,
		},
		{
			label:"机构基本情况-机构名称",
			prop:"organizationName",
			type: 'text',
			maxlength: '50',
			showWordLimit: true,
		},
		{
			label:"机构基本情况-机构电话",
			prop:"organizationPhone",
			type: 'text',
			maxlength: '11',
			showWordLimit: true,
		},
		{
			label:"社会公示情况说明",
			prop:"publicityNote",
			type: 'text',
			maxlength: '500',
			showWordLimit: true,
		},
		{
			label:"机构基本情况-核定床位数",
			prop:"realBedNum",
			append:"张",
			type:'text'
		},
		{
			label:'补贴唯一值',
			prop:"soleValue"
		},
		{
			label:'补助核准备注-补助核准备注日期',
			prop:"stopSubsidyApprovalDate",
			type:"date",
			format:"YYYY年MM月DD日",
			valueFormat:"YYYY-MM-DD"
		},
		{
			label:'补助核准备注-停止享受补助时间',
			prop:"stopSubsidyDate",
			type:"date",
			format:"YYYY年MM月DD日",
			valueFormat:"YYYY-MM-DD"
		},
		{
			label:'补助核准备注-经办人',
			prop:"stopSubsidyOperatorName",
			type: 'text',
			maxlength: '20',
			showWordLimit: true,
		},
		{
			label:'补助核准备注-停止享受补助其他原因',
			prop:"stopSubsidyOtherReason",
			type: 'text',
			maxlength: '500',
			showWordLimit: true,
		},
		{
			label:'补助核准备注-停止享受补助原因',
			prop:"stopSubsidyReason",
			type: 'text',
			maxlength: '500',
			showWordLimit: true,
		},
		{
			label:"申请内容-补贴总金额(小写)",
			prop:"subsidyTotalAmount",
			append:"元",
			type:"input"
		},{
			label:"申请内容-补贴总金额(大写)",
			prop:"subsidyTotalAmountText",
			type:"input"
		}

	]
}
const moreSearchConfig:any = {
	inline: true,
	showBtn: false,
	labelPosition: 'left',
	column:[
		...configToSearch(moreSet.column)
	]
}
export const baseConfig: any = {
	pageName: '“五类老人”入住机构补贴',
	dictcodes: ['MATERIAL_TRUTH_TYPE','ABILITY_STATUS','DEMUR_STATUS','DEMUR_STATUS','RESULT','ABILITY_LEVEL_CITY_STANDARD'],
	rowKey: 'id',
	tipLabel: 'organizationName',
	// exportMqTopic: '/ning/export',
	exportMqTopic: [
		{
			topic: '/ning/export/dpOrgFiveSubsidy/',
			label: '五类老人入住机构补贴信息',
			code: 3007,
			po: 'dpOrgFiveSubsidyPO',
		},
		{
			topic: '/ning/export/dporOrgFiveSubsidyRoster/',
			label: '五类老人入住机构补贴花名册',
			code: 3008,
			po: 'dporOrgFiveSubsidyRosterPO',
		},
		{
			topic: '/ning/export/dpOrgFiveSubsidyApply/',
			label: '“五类老人”入住养老机构补贴-申请内容',
			code: 3100,
			po: 'dpOrgFiveSubsidyApplyPO',
		},
	],
	api: {
		moreSearch:"view_dpOrgFiveSubsidy_search",
		index: 'dpOrgFiveSubsidy_page',
		delete: 'dpOrgFiveSubsidy_del',
		export: 'view_dpOrgFiveSubsidy_exportAll',
		import: 'dpOrgFiveSubsidy_import',
	},
	auth: {
		index: 'view_dpOrgFiveSubsidy_page',
		mulitSet: 'mulitSet',
		delete: 'view_dpOrgFiveSubsidy_del',
		// export: 'view_dpOrgFiveSubsidy_exportAll',
		// import: 'view_dpOrgFiveSubsidy_import',
	},
	paramsObj: {
		code: 3007,
	},
	menuBtn: [
		{
			icon: 'editor',
			label: '查看详情',
			type: 'primary',
			operate: 'Detail',
			auth: '',
			text: true,
			show: true,
		},
	],
	dialogConfig: {
		width: '65%',
	},
	moreSearchConfig,
	searchConfig: {
		inline: true,
		showBtn: true,
		labelPosition: 'left',
		column: [
			{
				label: '信用代码',
				prop: 'creditCode',
				type: 'input',
				span: 6,
			},
			{
				label: '机构名称',
				prop: 'organizationName',
				type: 'input',
				span: 6,
			},
			{
				label: '联系方式',
				prop: 'organizationPhone',
				type: 'input',
				span: 6,
			},
			{
				label: '所属地区',
				prop: '',
				propName: 'areas_name',
				type: 'AplidAreaSelect',
				span: 6,
			},
			{
				label: '联系人',
				prop: 'deputyUserName',
				type: 'input',
				span: 6,
			},
			{
				label: '申请年月',
				prop: 'applyTimeBetween',
				type: 'daterange',
				format: 'YYYY年MM月DD日',
				valueFormat: 'YYYY-MM-DD',
				span: 12,
			},
		],
	},
	tableConfig,
	beforeOnLoadFormate: async (params) => {
		params = toSearchHandle(moreSearchConfig,{},params)
		if(params.applyTimeBetween){
			params.applyTimeBetween = params.applyTimeBetween.join(',')
		}else{
			params.applyTimeBetween = undefined
		}
		let areasObj = getAreaObj(params.areas_name, 'belong')
		return Promise.resolve({
			...params,
			...areasObj,
			areas_name: undefined,
		})
	},
	onLoadFormate: async (arr) => {
		console.log('参数二', arr)
		const tableData = arr.map((item) => {
			const areas_name = getAreaObj(item, 'belong')
			return {
				...item,
				areas_name,
			}
		})
		return Promise.resolve(Object.freeze(tableData))
	},
}
